﻿using System;
using System.Drawing;
using System.Windows.Forms;
using LeakView.common;
using LeakView.service;
using log4net;

namespace LeakView
{
    static class Program
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(Program));
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {

            log.Info(System.Text.Encoding.Default);

            // 初始化winform支持
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            log.Info("Application starting...");

            Console.WriteLine("-----------------------------------------------");
            Console.WriteLine(string.Format("{0:D2}:00-{0:D2}:15", 1, 1));

            AppDomain.CurrentDomain.UnhandledException +=
                    new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);

            var conf = AnyConfigs.get("TEST");
            conf.set("HeadColor", System.Drawing.ColorTranslator.ToHtml(Color.FromArgb(2342)));

            using (ModuleManager manager = new ModuleManager())
            {

                manager.Register(new MainModule());
                manager.Register(MiscModal.me);

                manager.Register(SoundManager.me);
                manager.Start();

                log.Info(" Starting Modules...");


                Application.Run(new MainFrame());

            }

        }

        static void UnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs e)
        {
            log.Fatal("Unhandled Exception" + e.ExceptionObject);
        }
    }
}
